<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Password Toggle Inside Input</title>
    <style>
        .passwordbox {
          position: relative;
          display: inline-block;
        }
  
        #password {
          padding-right: 30px;
          box-sizing: border-box;
        }
  
        #xianshimima {
          position: absolute;
          right: 8px;
          top: 50%;
          transform: translateY(-50%); 
          cursor: pointer;
          width: 20px;
          height: 20px;
          opacity: 0.5;
        }
  
        #xianshimima:hover {
          opacity: 1;
        }
      </style>
</head>

<body>
    <div class="passwordbox">
        <input type="password" id="password" placeholder="请输入密码">
        <img src="eye-closed.png" id="xianshimima" alt="Xianshimima" onclick="mima()">
    </div>

    <script>
        function mima() {
            const passwordInput = document.getElementById('password');
            const xianshiButton = document.getElementById('xianshimima');

            if (passwordInput.type === 'password') {
                passwordInput.type = 'text';
                xianshiButton.src = 'eye-open.png';
            } else {
                    passwordInput.type = 'password';
                    xianshiButton.src = 'eye-closed.png';
                }
        }
    </script>
</body>
</html>